/**
 * 判断是否为空
 * @param obj
 */
export const isNull = (obj: any): boolean => (obj === null || typeof obj === 'undefined' || obj.trim() === '')

/**
 * 字符串超出省略
 * @param text 字符串
 * @param beyond 超出长度
 */
export const textBeyond = (text: string, beyond: number) => (text.length >= beyond ? text.slice(0, beyond) + '...' : text)

/**
 * 防抖函数
 * @param fn 函数
 * @param delay 防抖时间
 */
export const debounce = <T extends (...args: any[]) => void>(fn: T, delay: number): (...args: Parameters<T>) => void => {
        let timer: ReturnType<typeof setTimeout> | null = null

        return function (this: ThisParameterType<T>, ...args: Parameters<T>) {
            if (timer) clearTimeout(timer)
            timer = setTimeout(() => {
                fn.apply(this, args)
            }, delay)
        }
    }

